﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Compression;

namespace QuadRemote.Core
{
    public class StorageWriter : BinaryWriter
    {
        public StorageWriter(String name) : base(new GZipStream(new FileStream(name, FileMode.OpenOrCreate),CompressionMode.Compress))
        {

        }

        public void startList(String name)
        {
            Write((byte)StorageMarker.LIST_BEGIN);
            Write(name);
        }
        public void endList()
        {
            Write((byte)StorageMarker.LIST_END);
        }
        public void listString(String name, String value)
        {
            Write((byte)StorageMarker.LIST_STRING);
            Write(name);
            Write(value);
        }
        public void listInt(String name, int i)
        {
            Write((byte)StorageMarker.LIST_INT);
            Write(name);
            Write(i);
        }
        public void listBool(String name, bool a)
        {
            Write((byte)StorageMarker.LIST_BOOL);
            Write(name);
            Write(a);
        }
        public void listByteArray(String name, int length)
        {
            Write((byte)StorageMarker.LIST_ARRAY);
            Write(name);
            Write(length);
        }
    }
}
